package toutiao.t2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    static ArrayList<ResNode> res = new ArrayList<>();

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Node root = new Node(' ', 0, -1);
        for(int i=0;i<n;i++){
            String str = scanner.next();
            addTireNode(str, root, i);
        }
        ArrayList<Character> list = new ArrayList<>();
        getResult(root, list);
        Collections.sort(res);
        res.forEach(resNode->{
            System.out.println(resNode.str);
        });


    }

    public static void getResult(Node node, ArrayList<Character> list){
        for(int i=0;i<26;i++){
            if(null == node.nodes[i]) {
//                System.out.println(" ");
                continue;
            }
//            System.out.println(node.nodes[i].c+" "+node.nodes[i].num);
            ArrayList<Character> nList = new ArrayList<>(list);
            if(node.nodes[i].num == 1){
                nList.add(node.nodes[i].c);
                res.add(new ResNode(changeListToString(nList), node.nodes[i].ind));
            }else if(node.nodes[i].num > 1){
                nList.add(node.nodes[i].c);
                getResult(node.nodes[i], nList);
            }
        }
    }

    public static String changeListToString(ArrayList<Character> list){
        StringBuilder sb = new StringBuilder();
        list.forEach(c->{sb.append(c);});
        return sb.toString();
    }

    public static void addTireNode(String str, Node root, int ind){
        Node cur = root;
        for(int i=0;i<str.length();i++){
            int tmpInd = str.charAt(i)-'a';
            if(null != cur.nodes[tmpInd]) {
                cur.nodes[tmpInd].num++;
            }else{
                cur.nodes[tmpInd] = new Node((char)('a'+tmpInd), 1, ind);
            }
            cur = cur.nodes[tmpInd];
        }
    }

}


class Node{
    char c;
    int num;
    int ind;
    Node[] nodes = new Node[26];

    public Node(char c, int num, int ind) {
        this.c = c;
        this.num = num;
        this.ind = ind;
    }
}

class ResNode implements Comparable<ResNode>{
    String str;
    int ind;

    public ResNode(String str, int ind) {
        this.str = str;
        this.ind = ind;
    }

    @Override
    public int compareTo(ResNode o) {
        return this.ind - o.ind;
    }
}